#include <standard.hlsli>
#include <WR2Parameters.hlsli>

VertexToPixel vs_main(VS_INPUT Input)
{
	VertexToPixel Output = (VertexToPixel)0;
	Output.pos = float4(mul(Input.Position, worldViewProj));
	Output.normal = normalize(mul(Input.Normal, (float3x3)world));
	Output.kBlend.xyz = float3(Input.kblend.rgb);
	Output.pos2 = Input.Position;
	Output.texCoord2 = float4(Input.Position.x * uvTexture1a.x + Input.Position.y * uvTexture1a.y + Input.Position.z * uvTexture1a.z + uvTexture1a.w,
		Input.Position.x * uvTexture1b.x + Input.Position.y * uvTexture1b.y + Input.Position.z * uvTexture1b.z + uvTexture1b.w, 0, 0);
	return Output;
};

struct PixelToFrame
{
	float4 Color;
};

PixelToFrame ps_main(VertexToPixel PSIn) : SV_TARGET
{
	PixelToFrame Output = (PixelToFrame)0;
	float4 Lay1 = xColoredTexture1_Tex.Sample(Tex1, PSIn.texCoord2.xy);
		float4 TexColor = float4((Lay1.rgb * 0.05f + PSIn.kBlend.rgb * 0.25f + materialColor.rgb * 0.7f), 1.0f);
		Output.Color = TexColor;

	if (paintHighLines)
	{
		if (abs(PSIn.pos2.y) % 100.0f > 0.9f && abs(PSIn.pos2.y) % 100.0f  < 3.1f)
		{
			Output.Color.rgba = float4(1.0f, 0.0f, 0.0f, 0.5f);
		}
		else if (abs(PSIn.pos2.y) % 20.0f > 0.9f && abs(PSIn.pos2.y) % 20.0f < 3.1f)
		{
			Output.Color.rgba = float4(Output.Color.xyz * 1.5f, 0.50f);
		}
	}
	return  Output;
}

technique MaterialColor
{
	pass Material00
	{
		VertexShader = compile vs_1_1 vs_main();
		PixelShader = compile ps_2_0 ps_main();
	}
}